/*
 * @author Chris
 * @since 2023/1/23 22:02
 *
 * @brief    The project will ...
 *
 * @note     ...
 *
 * @warning  Do not to ...
 *
 * Change Logs:
 *   Date           Author       Notes
 *   2023-01-25     Chris        the first version
 */

#include "reg51.h"

void ConfigUART(unsigned int baud);

int main() {
    EA = 1;

    ConfigUART(9600);

    while (1);
}

void ConfigUART(unsigned int baud) {
    SCON |= 0x50;
    TMOD |= 0x20;
    TH1 = 256 - (11095200 / 12 / 2 / 16) / baud;
    TL1 = TH1;

    ET1 = 0;
    ES = 1;
    TR1 = 1;
}

/**
 * 串口中断中断服务函数
 */
void InterruptUART() __interrupt(4) {
    if (RI) {
        RI = 0;
        SBUF += 1;
    }
    if (TI) {
        TI = 0;
    }
}